package com.design.factoryPattern;

/**
 * 工厂设计模式
 */
public class PhoneFactory {
    public static void main(String[] args) {
        Phone huawei = new HuaWeiFactory().createPhone();
        huawei.whoAmI();
    }
}

interface Phone{
    void whoAmI();
}

class IPhone implements Phone{

    @Override
    public void whoAmI() {
        System.out.println("IPhone");
    }
}

class HuaWeiPhone implements Phone{
    @Override
    public void whoAmI(){
        System.out.println("HuaWei");
    }
}

interface Factory{
    Phone createPhone();
}

class IPhoneFactory implements Factory{

    @Override
    public Phone createPhone() {
        return new IPhone();
    }
}

class HuaWeiFactory implements Factory{

    @Override
    public Phone createPhone() {
        return new HuaWeiPhone();
    }
}
